package com.kordar.rbac;

import lombok.Data;
import org.springframework.util.SerializationUtils;

import java.util.Date;

@Data
public class Rule {
    /**
     * string name of the rule
     */
    private String name;

    private byte[] data;
    /**
     * int UNIX timestamp representing the rule creation time
     */
    private Date createTime;
    /**
     * int UNIX timestamp representing the rule updating time
     */
    private Date updateTime;

    public void setExecutor(Executor executor) {
        this.setData(SerializationUtils.serialize(executor));
    }

    public Executor getExecutor() {
        return (Executor) SerializationUtils.deserialize(this.getData());
    }
}
